<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String operation = request.getParameter("operation");
%>
<!DOCTYPE html>
<html lang="en">
<head>
	<%@ include file="/common/common-css.jsp" %>
	<style>
		.table > th {
		  vertical-align: center;
		  background-color: grey;
		}
	</style>		
</head>
<body class="no-skin">
	<div class="page-content">
			<div class="page-header"></div>
		<div class="page-content-area">
			<div class="row">
				<div class="col-xs-12 col-sm-12 widget-container-col">
					<div class="widget-box widget-color-blue">
						<!-- #section:custom/widget-box.options.collapsed -->
						<div class="widget-header widget-header-small">
							<h6 class="widget-title lighter">
								<i class="ace-icon glyphicon glyphicon-th-list"></i>基本信息
							</h6>
                            <div class="widget-toolbar no-border">
								<a href="#" data-action="collapse">
									<i class="ace-icon fa fa-chevron-up"></i>
								</a>
							</div>
						</div>
						
						<div class="widget-body">
							<div class="widget-main" >
								
								<form class="form-horizontal" id="queryForm" method="post" enctype="multipart/form-data" >
									
									<input type="hidden" name="id"  id="id" placeholder="" class="col-xs-12 col-sm-6" value="${paramsMap.model.id}">
									
									<table id="baseinfo" class="table table-bordered table-striped table-hover table-condensed table-responsive table">
                                        
                                        <tr>
											<th style="width:100px">活动类型</th>
											<td colspan="7">
												<select name="activity_type" id="activity_type">
													<option value="1">申请贷款送话费</option>
													<option value="2">邀请好友送话费</option>
												</select>
											</td>
										</tr>
										
										<tr>
											<th style="width:100px">所属活动</th>
											<td colspan="7">
												<s:select id="activityList" name="activity"
													list="%{paramsMap.activityList}" listKey="activity_id"
													listValue="activity_name" cssClass="form-control"></s:select>
											</td>
										</tr>

										<tr>
											<th style="width:100px">预计建单价格</th>
											<td colspan="7">
												<input type="text" name="amount" id="amount" placeholder="" value="${paramsMap.model.amount}" class="col-xs-12 col-sm-4" style="width:600px"/>
											</td>
										</tr>
										
										<tr>
											<th style="width:100px">备注</th>
											<td colspan="7">
												<input type="text" name="remark" id="remark" placeholder="" value="${paramsMap.model.remark}" class="col-xs-12 col-sm-4" style="width:600px"/>
											</td>
										</tr>
										<tr>
											<th style="width:100px">标签类型</th>
											<td colspan="7">
												<input type="text" name="tag_type" id="tag_type" placeholder="" value="${paramsMap.model.tag_type}" class="col-xs-12 col-sm-4" style="width:600px"/>
											</td>
										</tr>
										
										
									</table>
								</form>
									
							</div><!-- /.widget-main -->
						</div><!-- /.widget-body -->
						
					</div><!-- /.widget-box -->
				</div><!-- /.col-sm-12 -->
			</div><!-- /.row -->
				
					<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button class="btn  btn-inverse  no-border " onclick="doCancle()" id="delete"> 
								<i class="ace-icon fa fa-undo bigger-160"></i>
								取消
							</button>
			
							&nbsp; &nbsp; &nbsp;
							<button id="btn-save" name="btn-save" class="btn  btn-success  no-border" type="button" onclick="doSave()">
								<i class="ace-icon fa fa-floppy-o bigger-160"></i>
								保存
							</button>
						</div>
					</div>
				
			</div>
		</div>

<%@ include file="/common/common-js.jsp" %>
<%@ include file="/discovery/maxlength.jsp" %>

<script type="text/javascript" src="${ctx}/js/jquery.form.js"></script>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>

<script>

$(function(){
	// 数据回显
	var id = "${paramsMap.model.id}";
	if (id != null && id != "") {
		var activity = "${paramsMap.model.activity_id}";
		$("#activityList option[value=" + activity + "]").attr("selected", true);
		$("#activityList").attr("disabled",true);
		
		var activity_type = "${paramsMap.model.activity_type}";
		$("#activity_type option[value=" + activity_type + "]").attr("selected", true);
		$("#activity_type").attr("disabled",true);
	}
});


function doCancle() {
	try {
		if (parent) {
			parent.parent['__extdialog_active'].dialog('close');
		}
	} catch (e) {
		window.history.back();
	}
};

function doSave() {
	// 校验数据
	if($("#amount").val()==""){
		return alert("建单价格不能为空");
	}
	$("#activityList").attr("disabled", false);
	$("#activity_type").attr("disabled", false);
	saveForm();
};

function saveForm() {
	var saveUrl = ctx + "/loanhandphone/editInfo.action";
	console.log(saveUrl);
	var options = {
		url : saveUrl,
		type : "POST",
		dataType : "json",
		beforeSend : function() {
			$(".load_bg,.load_img").show();
		},
		success : function(data) {
			parent.parent['__extdialog_active'].dialog('close');
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			alert(textStatus);
			console.log(XMLHttpRequest, textStatus, errorThrown);
		},
		complete : function() {
			$(".load_bg,.load_img").hide();
		}
	};
	$('#queryForm').ajaxSubmit(options);
};

//接受URL参数，进行文档写入
function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null)
		return decodeURI(r[2]);
	return null;
}
</script>	
</body>
</html>
